﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;

namespace BDSim
{
    public class TrackSimpleCommand:ICommand
    {
        /// <summary>
        /// 命令可以执行的条件
        /// </summary>
        public Predicate<object> DlgCanExecuted { get; set; }
        /// <summary>
        /// 命令执行的事件
        /// </summary>
        public Action<object> DlgExecuted { get; set; }
        /// <summary>
        /// 继承ICommand的接口方法
        /// </summary>
        /// <param name="param">接口参数</param>
        /// <returns></returns>
        public bool CanExecute(object param)
        {
            bool flag = true;
            if (DlgCanExecuted != null)
            {
                flag = DlgCanExecuted(param);
            }
            return flag;
        }
        /// <summary>
        /// 继承ICommand的接口方法
        /// </summary>
        /// <param name="param">接口参数</param>
        public void Execute(object param)
        {
            if (DlgExecuted != null)
            {
                DlgExecuted(param);
            }
        }
        /// <summary>
        /// 继承ICommand的接口事件
        /// </summary>
        public event EventHandler CanExecuteChanged
        {
            add { CommandManager.RequerySuggested += value; }
            remove { CommandManager.RequerySuggested -= value; }
        }
    }
}
